template.helper('dateFormat', function (date, format) {
	if (date){
        date = new Date(Unix2Time(date, 1000));
        return date.format(format);
	}else{
		return '';
	}
});


template.helper('UserTime', function (date) {
	var h = parseInt(date/3600) ? parseInt(date/3600)+ "小时" : "";
	var n = parseInt(date/60) ? parseInt(date/60)+ "分" : "";
    var b = h + n + date%60 + "秒";
    return b;
});

template.helper('endpro', function (s, e) {
	var time = UnixTime(1);
    var time2 = e - s;
    return  Math.round(((time - s) / time2)*100, 0) +'%';
});

template.helper('unicode', function (str) {
	str=str.replace(/\\/g,"%");
    return unescape(str);
});


template.helper('number2az', function (str) {
    return String.fromCharCode((65+parseInt(str)));
});

function uploads(src, path, fullpath) {
	fullpath = (fullpath) ? 'http://'+window.location.host : '';
	if (path == '_avatar_'){
		path = '';
		src = src!='' ? src : projectName+'/static/webapp/images/default_head (2).png';
		//src!='' ? src : projectName+'/static/webapp/images/default_head (2).png';
	}else{
	    path = path ? path : '';
	}
	var domin = (src+'').substr(0,7) != 'http://' ? fullpath+projectName+path+'/' : '';
    return domin+src;
}
/*图片完整URL*/
template.helper('uploads', function (src, path) {
    return uploads(src, path);
});
